package com.lanqiao.gxnushop.service;

import com.lanqiao.gxnushop.entity.Reviews;
import com.lanqiao.gxnushop.mapper.ReviewsMapper;
import com.lanqiao.gxnushop.util.UUIdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class ReviewsService {
    @Autowired
    private ReviewsMapper reviewsMapper;

    /**添加评价*/
    public boolean add(Reviews reviews) {
        reviews.setReviewId(UUIdUtil.getUserId());
        return reviewsMapper.add(reviews);
    }
    /***删除评价*/
     public boolean delete(String reviewId){
         return reviewsMapper.delete(reviewId);
     }

     /**根据买家id查询评价 买家的所有评价*/
     public ArrayList<Reviews> findByBuyerId(String buyerId){
         return reviewsMapper.findByBuyerId(buyerId);
     }

     /**根据评价的id查询评价*/
     public Reviews selectByReviewId(String reviewId){
         return reviewsMapper.findById(reviewId);
     }
     /**更新评价*/
     public boolean update (Reviews reviews){
         return reviewsMapper.update(reviews);
     }

     /**根据商品Id查找该商品的所有评价*/
     public ArrayList<Reviews> selectByProductId(String productId){
         return reviewsMapper.findByProductId(productId);
     }
}
